#include "Hw3Types.h"
#include "Hw3TypesExtended.h"


/*oOoOoOoOoOoOoOoOoOoOoOoOooOoOoOoOoOoO*/
//			Output Module
/*oOoOoOoOoOoOoOoOoOoOoOoOooOoOoOoOoOoO*/
// This module is in charge of initializing the output files, writing to them, protecting them from
// simultaneous access by multiple threads, allowing only a single write to each file, closing the files and
// freeing the resources.

// InitializeOutputs
// =================
// This function opens the output file and the end file, as well as the mutexes that protects them from being written
// more than once. 
// Inputs: 
//		- OutputFileName - A string with the name of the output file. The output file will contain the coordinates
//							of the first duplicate faces found, or nothing in case no duplicate faces were found or 
//							error occured.
//		- EndReasonFileName - A string with the name of the end file. The end file will contain the reason the 
//								program exited - an error, duplicate faces found, etc.
// Output: Success - TRUE. Failure - FALSE.
BOOL InitializeOutputs(const char * OutputFileName, const char *EndReasonFileName);

// FreeOutputs
// ===========
// Closes the handles to the output and end files, as well as the mutexes that protects them from being written
// more than once. 
void FreeOutputs();

// WriteOutputFile
// ===============
// Writes the coordinates of the duplicate faces found. The output file is a "write-once", so only the first duplicate
// couple will be written.
// Inputs: Two pointers to a TFace struct containing the information about the duplicate faces.
// Output: Success - TRUE. Failure - FALSE.
BOOL WriteOutputFile(TFace *FirstFace, TFace *SecondFace);

// WriteEndFile
// ===============
// Writes the end reason to the end file. The end file is a "write-once", so only the first call to this function 
// will actually write the message to the end file.
// Inputs: A string containing an informative message about the reason the program has finished. 
BOOL WriteEndFile(char *EndString);
